package com.yaoyou.dao;

import com.yaoyou.model.dataObject.MedicineRemindRecord;
import com.yaoyou.model.dataObject.MedicineRemindRecordExample;
import java.util.List;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.DeleteProvider;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;

public interface MedicineRemindRecordMapper {
    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table MEDICINE_REMIND_RECORD
     *
     * @mbggenerated Fri Aug 19 17:50:34 CST 2016
     */
    @SelectProvider(type=MedicineRemindRecordSqlProvider.class, method="countByExample")
    int countByExample(MedicineRemindRecordExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table MEDICINE_REMIND_RECORD
     *
     * @mbggenerated Fri Aug 19 17:50:34 CST 2016
     */
    @DeleteProvider(type=MedicineRemindRecordSqlProvider.class, method="deleteByExample")
    int deleteByExample(MedicineRemindRecordExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table MEDICINE_REMIND_RECORD
     *
     * @mbggenerated Fri Aug 19 17:50:34 CST 2016
     */
    @Delete({
        "delete from MEDICINE_REMIND_RECORD",
        "where ID = #{id,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer id);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table MEDICINE_REMIND_RECORD
     *
     * @mbggenerated Fri Aug 19 17:50:34 CST 2016
     */
    @Insert({
        "insert into MEDICINE_REMIND_RECORD (ID, USER_ID, ",
        "TIME, MEDICINE_NAME)",
        "values (#{id,jdbcType=INTEGER}, #{userId,jdbcType=VARCHAR}, ",
        "#{time,jdbcType=VARCHAR}, #{medicineName,jdbcType=VARCHAR})"
    })
    int insert(MedicineRemindRecord record);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table MEDICINE_REMIND_RECORD
     *
     * @mbggenerated Fri Aug 19 17:50:34 CST 2016
     */
    @InsertProvider(type=MedicineRemindRecordSqlProvider.class, method="insertSelective")
    int insertSelective(MedicineRemindRecord record);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table MEDICINE_REMIND_RECORD
     *
     * @mbggenerated Fri Aug 19 17:50:34 CST 2016
     */
    @SelectProvider(type=MedicineRemindRecordSqlProvider.class, method="selectByExample")
    @Results({
        @Result(column="ID", property="id", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="USER_ID", property="userId", jdbcType=JdbcType.VARCHAR),
        @Result(column="TIME", property="time", jdbcType=JdbcType.VARCHAR),
        @Result(column="MEDICINE_NAME", property="medicineName", jdbcType=JdbcType.VARCHAR)
    })
    List<MedicineRemindRecord> selectByExample(MedicineRemindRecordExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table MEDICINE_REMIND_RECORD
     *
     * @mbggenerated Fri Aug 19 17:50:34 CST 2016
     */
    @Select({
        "select",
        "ID, USER_ID, TIME, MEDICINE_NAME",
        "from MEDICINE_REMIND_RECORD",
        "where ID = #{id,jdbcType=INTEGER}"
    })
    @Results({
        @Result(column="ID", property="id", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="USER_ID", property="userId", jdbcType=JdbcType.VARCHAR),
        @Result(column="TIME", property="time", jdbcType=JdbcType.VARCHAR),
        @Result(column="MEDICINE_NAME", property="medicineName", jdbcType=JdbcType.VARCHAR)
    })
    MedicineRemindRecord selectByPrimaryKey(Integer id);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table MEDICINE_REMIND_RECORD
     *
     * @mbggenerated Fri Aug 19 17:50:34 CST 2016
     */
    @UpdateProvider(type=MedicineRemindRecordSqlProvider.class, method="updateByExampleSelective")
    int updateByExampleSelective(@Param("record") MedicineRemindRecord record, @Param("example") MedicineRemindRecordExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table MEDICINE_REMIND_RECORD
     *
     * @mbggenerated Fri Aug 19 17:50:34 CST 2016
     */
    @UpdateProvider(type=MedicineRemindRecordSqlProvider.class, method="updateByExample")
    int updateByExample(@Param("record") MedicineRemindRecord record, @Param("example") MedicineRemindRecordExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table MEDICINE_REMIND_RECORD
     *
     * @mbggenerated Fri Aug 19 17:50:34 CST 2016
     */
    @UpdateProvider(type=MedicineRemindRecordSqlProvider.class, method="updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(MedicineRemindRecord record);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table MEDICINE_REMIND_RECORD
     *
     * @mbggenerated Fri Aug 19 17:50:34 CST 2016
     */
    @Update({
        "update MEDICINE_REMIND_RECORD",
        "set USER_ID = #{userId,jdbcType=VARCHAR},",
          "TIME = #{time,jdbcType=VARCHAR},",
          "MEDICINE_NAME = #{medicineName,jdbcType=VARCHAR}",
        "where ID = #{id,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(MedicineRemindRecord record);

    @Select({
            "select distinct user_id, time",
            "from MEDICINE_REMIND_RECORD",
            "where user_id = #{user_id,jdbcType=VARCHAR}",
            "order by TIME DESC ",
            "LIMIT #{offset},#{limit}"
    })
    List<MedicineRemindRecord> selectDistinctUserTimeListByLimit(@Param("user_id") String userId, @Param("offset") int offset, @Param("limit") int limit);

    @Select({
            "select distinct user_id, time",
            "from MEDICINE_REMIND_RECORD",
            "where user_id = #{user_id,jdbcType=VARCHAR}"
    })
    List<MedicineRemindRecord> selectDistinctUserTimeList(@Param("user_id") String userId);

}